package {


import flash.utils.Dictionary;

import lzm.starling.STLStarup;

import starling.core.Starling;

import utils.ArrayList;
import utils.Kit;
import utils.VectorList;

[SWF(frameRate=60, width=720, height=1280)]
public class Main extends STLStarup {
    public function Main() {

        //the AssetManager will automatically restore all loaded textures.
        Starling.handleLostContext = true;

        stage.color = 0x00ffff;

        //initStarlingWithWH(GameRootTest, 720, 1280, 9999, 3, true);
        initStarlingWithWH(GameRoot, 720, 1280, 9999, 3, false);

    }


    /**
     * map 测试
     */
    private function testMap():void {
        var map:Dictionary = new Dictionary();
        var key:Object = new Object();
        map[key] = 12;
        map[2] = 13;
//        trace("value:", map[1]);

        for each(var value:int in  map) {
            trace("value:", value);
        }


        delete map[key];
        key = null;

        trace("value:", map[1]);
    }

    /**
     */
    private function testList():void {
        var list:ArrayList = new ArrayList();
        list.addAll(1, 2, 3, 4, 5);
        list.add(8);

        var size:int = list.size();
        trace(size);

        trace("value:" + list.toString());

        //remove
        var remove_obj:int = list.removeIndex(0);


        var remove_obj1:int = list.removeObject(5);

        trace("remove_obj:", remove_obj, "remove_obj1:", remove_obj1);

        trace("last size:", list.size());

        trace("clear all:");
        list.clear();
        trace("size:", list.size());
    }


    /**
     *
     */
    private function testVector():void {

        var list:VectorList = new VectorList();
        list.addAll(1, 2, 3, 4, 5);
        list.add(8);

        var size:int = list.size();
        trace(size);

        trace("value:" + list.toString());

        //remove
        var remove_obj:int = list.removeIndex(0);


        var remove_obj1:int = list.removeObject(5);

        trace("remove_obj:", remove_obj, "remove_obj1:", remove_obj1);

        trace("last size:", list.size());

        trace("clear all:");
        list.clear();
        trace("size:", list.size());
    }


    private function testRnd():Number {
        return Kit.Rnd(0.0, 1.0);
    }

    /**
     * as3  base test
     */
    public function test0():void {
        var index:Number = 10;
        trace(index + "");
        var object:Object = ["0000000"];// null

        var list:Vector.<Object> = new Vector.<Object>();


        list.push(object);


        /**
         *
         */
        list.forEach(function callBackVector(item:Object, index:int, arr:Vector.<Object>):void {
            trace("item:" + item + " index:" + index);
        });

        for each(var o:Object in list) {
            trace("item:" + o);
        }


        /**
         * index
         * for in
         */

        for (var pop in list) {
            trace("list index:" + pop + " value " + list[pop]);
        }


        for (var i:uint = 0; i != list.length; ++i) {
            trace(list[i]);
        }


        trace(list.pop());

        var array:Array = [];
        trace(array.toString())

        var obj:Object = ["a", "b", "c"];

        var newArray:Array = obj as Array;// cast array object

        trace(newArray == obj); // true
        trace(newArray[0]);     // a
        trace(newArray[1]);     // b
        trace(newArray[2]);     // c

        var instance:Boolean = obj instanceof Array;
        trace("obj instanceof Array :" + instance)


        var strValue:String = "190";
        trace(parseInt(strValue) as int);

        var v:Vector.<String>;
        v = new Vector.<String>();

        var vector:Vector.<String> = new Vector.<String>();
        var str:String = "石头哥哥";
        vector.push(str);
        vector.unshift(str);
        /**
         * for(:){
         *
         * }
         */
        for each(var value in vector) {
            trace(value);
        }

    }
}
}
